package com.wanmait.schedule.manageController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import com.wanmait.schedule.entity.Company;
import com.wanmait.schedule.entity.Menu;
import com.wanmait.schedule.service.AdminService;
import com.wanmait.schedule.service.CompanyService;
import com.wanmait.schedule.service.MenuService;
import com.wanmait.schedule.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/Manage")
public class InitDateController {

    @Resource
    private CompanyService companyService;
    @Resource
    private MenuService menuService;

    @GetMapping("/Context")
    public Result companies(Integer pageNum){//找到所有的企业
        if(pageNum==null){
            pageNum=1;
        }
        Page<Company> companies = companyService.companys(pageNum,10);
        return Result.success(companies);
    }
    @GetMapping("/keyword")
    public Result selectCompany(String keyword){//关键词搜索
        List<Company> companies = companyService.selectCompang(keyword);
        return Result.success(companies);
    }
    @GetMapping("/menu")
    public Result selectMenu(){//找到所有的菜单
        List<Menu> menus = menuService.menus();
        return Result.success(menus);
    }
    @GetMapping("/DelectMenu")//逻辑删除
    public void DelectMenu(Integer id){
        menuService.DeleteMenu(id);

    }
}
